<?php
namespace BaseExt;

use BaseExt\ChuangLan\ChuanglanSmsApi;

class SmsChanglan {

//    private $key = 'LTAI7rhhoIlxuh0U';
//    private $sec = 'l4ZJmXGbPbVBzuxLbzzqmaAUocswSX';

    public function sendSms($phone,$message)
    {
        $clapi  = new ChuanglanSmsApi();
//        $code = mt_rand(100000,999999);

        //设置您要发送的内容：其中“【】”中括号为运营商签名符号，多签名内容前置添加提交
        $result = $clapi->sendSMS($phone,$message );

        if(!is_null(json_decode($result))){

            $output=json_decode($result,true);

            if(isset($output['code'])  && $output['code']=='0'){
                return false;
            }else{
                return $output['errorMsg'];
            }
        }else{
            return $result;
        }
    }
}
